/*
* Copyright 2025 NXP
* NXP Proprietary. This software is owned or controlled by NXP and may only be used strictly in
* accordance with the applicable license terms. By expressly accepting such terms or by downloading, installing,
* activating and/or otherwise using the software, you are agreeing that you have read, and that you agree to
* comply with and are bound by, such license terms.  If you do not agree to be bound by the applicable license
* terms, then you may not retain, install, activate or otherwise use the software.
*/

#include "lvgl.h"
#include <stdio.h>
#include "gui_guider.h"
#include "events_init.h"
#include "widgets_init.h"
#include "custom.h"



lv_calendar_date_t page_calendar_calendar_today;
lv_calendar_date_t page_calendar_calendar_highlihted_days[1];
void setup_scr_page_calendar(lv_ui *ui)
{
    //Write codes page_calendar
    ui->page_calendar = lv_obj_create(NULL);
    lv_obj_set_size(ui->page_calendar, 480, 480);
    lv_obj_set_scrollbar_mode(ui->page_calendar, LV_SCROLLBAR_MODE_OFF);

    //Write style for page_calendar, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
    lv_obj_set_style_bg_opa(ui->page_calendar, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_color(ui->page_calendar, lv_color_hex(0x152029), LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_grad_dir(ui->page_calendar, LV_GRAD_DIR_VER, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_grad_color(ui->page_calendar, lv_color_hex(0x152029), LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_main_stop(ui->page_calendar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_grad_stop(ui->page_calendar, 255, LV_PART_MAIN|LV_STATE_DEFAULT);

    //Write codes page_calendar_calendar
    ui->page_calendar_calendar = lv_calendar_create(ui->page_calendar);
    lv_obj_set_pos(ui->page_calendar_calendar, 0, 45);
    lv_obj_set_size(ui->page_calendar_calendar, 480, 435);
    page_calendar_calendar_today.year = 2025;
    page_calendar_calendar_today.month = 7;
    page_calendar_calendar_today.day = 2;
    lv_calendar_set_today_date(ui->page_calendar_calendar, page_calendar_calendar_today.year, page_calendar_calendar_today.month, page_calendar_calendar_today.day);
    lv_calendar_set_showed_date(ui->page_calendar_calendar, page_calendar_calendar_today.year, page_calendar_calendar_today.month);
    page_calendar_calendar_highlihted_days[0].year = 2025;
    page_calendar_calendar_highlihted_days[0].month = 7;
    page_calendar_calendar_highlihted_days[0].day = 3;
    lv_calendar_set_highlighted_dates(ui->page_calendar_calendar, page_calendar_calendar_highlihted_days, 1);
    lv_obj_t *page_calendar_calendar_header = lv_calendar_header_arrow_create(ui->page_calendar_calendar);
    lv_calendar_t *page_calendar_calendar = (lv_calendar_t *)ui->page_calendar_calendar;
    lv_obj_add_event_cb(page_calendar_calendar->btnm, page_calendar_calendar_draw_part_begin_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL);
    lv_obj_add_event_cb(ui->page_calendar_calendar, page_calendar_calendar_event_handler, LV_EVENT_ALL, NULL);

    //Write style state: LV_STATE_DEFAULT for &style_page_calendar_calendar_main_main_default
    static lv_style_t style_page_calendar_calendar_main_main_default;
    ui_init_style(&style_page_calendar_calendar_main_main_default);

    lv_style_set_border_width(&style_page_calendar_calendar_main_main_default, 1);
    lv_style_set_border_opa(&style_page_calendar_calendar_main_main_default, 255);
    lv_style_set_border_color(&style_page_calendar_calendar_main_main_default, lv_color_hex(0xc0c0c0));
    lv_style_set_border_side(&style_page_calendar_calendar_main_main_default, LV_BORDER_SIDE_FULL);
    lv_style_set_bg_opa(&style_page_calendar_calendar_main_main_default, 255);
    lv_style_set_bg_color(&style_page_calendar_calendar_main_main_default, lv_color_hex(0xffffff));
    lv_style_set_bg_grad_dir(&style_page_calendar_calendar_main_main_default, LV_GRAD_DIR_NONE);
    lv_style_set_shadow_width(&style_page_calendar_calendar_main_main_default, 0);
    lv_style_set_radius(&style_page_calendar_calendar_main_main_default, 0);
    lv_obj_add_style(ui->page_calendar_calendar, &style_page_calendar_calendar_main_main_default, LV_PART_MAIN|LV_STATE_DEFAULT);

    //Write style state: LV_STATE_DEFAULT for &style_page_calendar_calendar_extra_header_main_default
    static lv_style_t style_page_calendar_calendar_extra_header_main_default;
    ui_init_style(&style_page_calendar_calendar_extra_header_main_default);

    lv_style_set_text_color(&style_page_calendar_calendar_extra_header_main_default, lv_color_hex(0xffffff));
    lv_style_set_text_font(&style_page_calendar_calendar_extra_header_main_default, &lv_font_montserratMedium_12);
    lv_style_set_text_opa(&style_page_calendar_calendar_extra_header_main_default, 255);
    lv_style_set_bg_opa(&style_page_calendar_calendar_extra_header_main_default, 255);
    lv_style_set_bg_color(&style_page_calendar_calendar_extra_header_main_default, lv_color_hex(0x2195f6));
    lv_style_set_bg_grad_dir(&style_page_calendar_calendar_extra_header_main_default, LV_GRAD_DIR_NONE);
    lv_obj_add_style(page_calendar_calendar_header, &style_page_calendar_calendar_extra_header_main_default, LV_PART_MAIN|LV_STATE_DEFAULT);

    //Write style state: LV_STATE_DEFAULT for &style_page_calendar_calendar_main_items_default
    static lv_style_t style_page_calendar_calendar_main_items_default;
    ui_init_style(&style_page_calendar_calendar_main_items_default);

    lv_style_set_bg_opa(&style_page_calendar_calendar_main_items_default, 255);
    lv_style_set_bg_color(&style_page_calendar_calendar_main_items_default, lv_color_hex(0xffffff));
    lv_style_set_bg_grad_dir(&style_page_calendar_calendar_main_items_default, LV_GRAD_DIR_NONE);
    lv_style_set_border_width(&style_page_calendar_calendar_main_items_default, 1);
    lv_style_set_border_opa(&style_page_calendar_calendar_main_items_default, 255);
    lv_style_set_border_color(&style_page_calendar_calendar_main_items_default, lv_color_hex(0xc0c0c0));
    lv_style_set_border_side(&style_page_calendar_calendar_main_items_default, LV_BORDER_SIDE_FULL);
    lv_style_set_text_color(&style_page_calendar_calendar_main_items_default, lv_color_hex(0x0D3055));
    lv_style_set_text_font(&style_page_calendar_calendar_main_items_default, &lv_font_montserratMedium_12);
    lv_style_set_text_opa(&style_page_calendar_calendar_main_items_default, 255);
    lv_obj_add_style(lv_calendar_get_btnmatrix(ui->page_calendar_calendar), &style_page_calendar_calendar_main_items_default, LV_PART_ITEMS|LV_STATE_DEFAULT);

    //Write codes page_calendar_c_appbar
    ui->page_calendar_c_appbar = lv_obj_create(ui->page_calendar);
    lv_obj_set_pos(ui->page_calendar_c_appbar, 0, 0);
    lv_obj_set_size(ui->page_calendar_c_appbar, 480, 45);
    lv_obj_set_scrollbar_mode(ui->page_calendar_c_appbar, LV_SCROLLBAR_MODE_OFF);

    //Write style for page_calendar_c_appbar, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
    lv_obj_set_style_border_width(ui->page_calendar_c_appbar, 2, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_border_opa(ui->page_calendar_c_appbar, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_border_color(ui->page_calendar_c_appbar, lv_color_hex(0x2195f6), LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_border_side(ui->page_calendar_c_appbar, LV_BORDER_SIDE_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_radius(ui->page_calendar_c_appbar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui->page_calendar_c_appbar, 20, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_color(ui->page_calendar_c_appbar, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_grad_dir(ui->page_calendar_c_appbar, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_top(ui->page_calendar_c_appbar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_bottom(ui->page_calendar_c_appbar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_left(ui->page_calendar_c_appbar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_right(ui->page_calendar_c_appbar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_shadow_width(ui->page_calendar_c_appbar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

    //Write codes page_calendar_c_back
    ui->page_calendar_c_back = lv_image_create(ui->page_calendar_c_appbar);
    lv_obj_set_pos(ui->page_calendar_c_back, 14, 8);
    lv_obj_set_size(ui->page_calendar_c_back, 30, 30);
    lv_obj_add_flag(ui->page_calendar_c_back, LV_OBJ_FLAG_CLICKABLE);
    lv_image_set_src(ui->page_calendar_c_back, &_back_RGB565A8_30x30);
    lv_image_set_pivot(ui->page_calendar_c_back, 50,50);
    lv_image_set_rotation(ui->page_calendar_c_back, 0);

    //Write style for page_calendar_c_back, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
    lv_obj_set_style_image_recolor_opa(ui->page_calendar_c_back, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_image_opa(ui->page_calendar_c_back, 255, LV_PART_MAIN|LV_STATE_DEFAULT);

    //Write codes page_calendar_label_calendar
    ui->page_calendar_label_calendar = lv_label_create(ui->page_calendar_c_appbar);
    lv_obj_set_pos(ui->page_calendar_label_calendar, 216, 16);
    lv_obj_set_size(ui->page_calendar_label_calendar, 48, 16);
    lv_label_set_text(ui->page_calendar_label_calendar, "日历");
    lv_label_set_long_mode(ui->page_calendar_label_calendar, LV_LABEL_LONG_WRAP);

    //Write style for page_calendar_label_calendar, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT.
    lv_obj_set_style_border_width(ui->page_calendar_label_calendar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_radius(ui->page_calendar_label_calendar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_color(ui->page_calendar_label_calendar, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_font(ui->page_calendar_label_calendar, &lv_font_SourceHanSerifSC_Regular_16, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_opa(ui->page_calendar_label_calendar, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_letter_space(ui->page_calendar_label_calendar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_line_space(ui->page_calendar_label_calendar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_text_align(ui->page_calendar_label_calendar, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui->page_calendar_label_calendar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_top(ui->page_calendar_label_calendar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_right(ui->page_calendar_label_calendar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_bottom(ui->page_calendar_label_calendar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_pad_left(ui->page_calendar_label_calendar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_obj_set_style_shadow_width(ui->page_calendar_label_calendar, 0, LV_PART_MAIN|LV_STATE_DEFAULT);

    //The custom code of page_calendar.


    //Update current screen layout.
    lv_obj_update_layout(ui->page_calendar);

    //Init events for screen.
    events_init_page_calendar(ui);
}
